﻿using System;
using SCG = System.Collections.Generic;

using Nemerle.Assertions;
using Nemerle.Utility;

using GASS.OpenCL;
using GASS.OpenCL.OpenCLDriver;

namespace Nemerle.OpenCL {

    [InfoProperty(CLSamplerInfo.ReferenceCount, int, Flags(no_cache))]
    [EqualityByIdPattern]
    public sealed class Sampler : IDisposable {

        public this([NotNull]context : Context, normalized_coords : bool, addressing_mode : CLAddressingMode, filter_mode : CLFilterMode) {
            this.handle = SamplerHandle(CheckErrorTail(clCreateSampler(context.Id, Utils.Converter.Convert(normalized_coords), addressing_mode, filter_mode)));
            this.context = context;
            this.normalized_coords = normalized_coords;
            this.addressing_mode = addressing_mode;
            this.filter_mode = filter_mode;
        }

        [Accessor] context : Context;

        handle : SamplerHandle;

        public Id : CLSampler {
            get { handle.EntityId }
        }

        [Accessor] normalized_coords : bool;

        [Accessor] addressing_mode : CLAddressingMode;

        [Accessor] filter_mode : CLFilterMode;

        #region IDisposable

        public Dispose() : void {
            when(null != handle)
                handle.Close();
        }

        #endregion

    }

}